package com.common.log.service;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;

import com.common.domain.BaseDomain;

/**
 * @author nickevin@gmail.com
 * @version Mar 28, 2009
 * 
 */

@Entity
@Table(name = "cms_log", catalog = "cms")
public class Log implements BaseDomain {

	private static final long serialVersionUID = 235844916276463423L;

	public Log() {}

	public Log(String loginId, String loginTime) {
		this.loginId = loginId;
		this.loginTime = loginTime;
	}

	public Log(String loginId, String loginTime, String ip) {
		this.loginId = loginId;
		this.loginTime = loginTime;
		this.ip = ip;
	}

	@Column(name = "login_id", nullable = false, length = 10)
	public String getLoginId() {
		return loginId;
	}

	public void setLoginId(String loginId) {
		this.loginId = loginId;
	}

	@Column(name = "login_time", nullable = false, length = 0)
	public String getLoginTime() {
		return loginTime;
	}

	public void setLoginTime(String loginTime) {
		this.loginTime = loginTime;
	}

	@Column(name = "login_ip", nullable = false, length = 15)
	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (ip == null ? 0 : ip.hashCode());
		result = prime * result
				+ (loginTime == null ? 0 : loginTime.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		final Log other = (Log) obj;
		if (ip == null) {
			if (other.ip != null) {
				return false;
			}
		} else if (!ip.equals(other.ip)) {
			return false;
		}
		if (loginTime == null) {
			if (other.loginTime != null) {
				return false;
			}
		} else if (!loginTime.equals(other.loginTime)) {
			return false;
		}
		return true;
	}

	private String loginId;
	private String loginTime;
	private String ip;
}
